package schoolWork.work02;

public class Java_3 {
    //点的坐标
    int x, y;

    //构造方法
    public Java_3() {
    }

    public Java_3(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Java_3(Java_3 p) {
        this.x = p.x;
        this.y = p.y;
    }

    //以对象的形式返回当前点的位置
    public Java_3 getLocation() {
        Java_3 p = new Java_3(x,y);
        return p;
    }
    //返回点的横坐标
    public int getX(){return x;}
    //返回点的纵坐标
    public int getY(){return y;}
    //把当前的点移动到新的位置
    public void move(int x,int y){
        this.x = x;
        this.y = y;
    }
    //以(x,y)的格式返回当前点的位置
    public String toString(){
        return "("+x+","+y+")";
    }
    //在原有的坐标上分别增加x和y
    public void translate(int x,int y){
        this.x+=x;
        this.y+=y;
    }
}
